package arith;

import java.util.Random;

public class Properties implements Input, Operation {
	
	Problem prob;
	
	public Properties(int id){
		Random random = new Random();
		int n1 = random.nextInt(99) + 1;
		int n2 = random.nextInt(99) + 1;
		int n3 = random.nextInt(99) + 1;
		int r = random.nextInt(2);
		if(id == 0){
			//Associative addition
			prob = new Problem("<assoc>");
			if(r == 0){
				prob.setProblem("Rewrite ("+n1+" + "+n2+")"+" + "+n3);
				prob.setSolution(n1+" + ("+n2+" + "+n3+")");
			}else{
				prob.setProblem("Rewrite "+n1+" + ("+n2+" + "+n3+")");
				prob.setSolution("("+n1+" + "+n2+")"+" + "+n3);
			}
		}
		if(id == 1){
			//Associative multiplication
			prob = new Problem("<assoc>");
			if(r == 0){
				prob.setProblem("Rewrite ("+n1+" * "+n2+")"+" * "+n3);
				prob.setSolution(n1+" * ("+n2+" * "+n3+")");
			}else{
				prob.setProblem("Rewrite "+n1+" * ("+n2+" * "+n3+")");
				prob.setSolution("("+n1+" * "+n2+")"+" * "+n3);
			}
		}
		if(id == 2){
			//Distributive
			prob = new Problem("<dist>");
			if(r == 0){
				prob.setProblem("Rewrite "+n1+" * ("+n2+" + "+n3+")");
				prob.setSolution("("+n1+" * "+n2+") + ("+n1+" * "+n3+")");
			}else{
				prob.setProblem("Rewrite ("+n1+" * "+n2+") + ("+n1+" * "+n3+")");
				prob.setSolution(n1+" * ("+n2+" + "+n3+")");
			}
		}
	}

	public Problem getProblem() {
		return prob;
	}

	public int id() {
		return 4;
	}

	public double value() {
		return 0;
	}

}
